package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.Impl.LeansnewsDaoImpl;
import com.ysd.dao.Impl.NewsCatalogueDaoImpl;
import com.ysd.dao.Impl.ShangXiaPianDaoImpl;
import com.ysd.entity.Leansnews;
import com.ysd.entity.NewsCatalogue;

public class NewsDetailServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//查询新闻分类
		NewsCatalogueDaoImpl lDao = new NewsCatalogueDaoImpl();
		List<NewsCatalogue> leanList=lDao.getNewsList();
		request.setAttribute("leanList", leanList);
		//通过id获取新闻详情
		int cpId = Integer.parseInt(request.getParameter("newsId"));
		LeansnewsDaoImpl newDao = new LeansnewsDaoImpl();		
		List<Leansnews> newList = newDao.getLeansnewList(cpId);
		request.setAttribute("newList", newList);
		//通过id获取上一篇的内容
		int cId = Integer.parseInt(request.getParameter("newsId"));
		ShangXiaPianDaoImpl sDao = new ShangXiaPianDaoImpl();		
		List<Leansnews> shangList = sDao.getShang(cId);
		request.setAttribute("shangList", shangList);
		//通过id获取下一篇的内容
		int xId = Integer.parseInt(request.getParameter("newsId"));
		ShangXiaPianDaoImpl xDao = new ShangXiaPianDaoImpl();		
		List<Leansnews> xiaList = xDao.getXia(xId);
		request.setAttribute("xiaList", xiaList);
		
		request.getRequestDispatcher("article_list_content.jsp").forward(request, response);		
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
